#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <climits>

using namespace std;
const int _N=1025;
int N,T1,T2,T3,T4;//数量,相同，上，下，切换
int v1[_N],v2[_N],dp1[_N],dp2[_N];
int ans=0x3f3f3f3f;


int main(){
    cin >> N>> T1 >> T2 >> T3 >> T4;
    for(int i=0;i<N;i++){
        cin >> v1[i];
        v2[i]=4-v1[i];
    }
    memset(dp1,0,sizeof(dp1));
    memset(dp2,0,sizeof(dp2));
    dp1[0]=0;
    dp2[0]=T4;
    for(int i=1;i<N;i++){
        if(v1[i-1]+1 <v1[i]){
            dp1[i]=min(dp1[i-1]+T4+T3+T4,dp2[i-1]+T3+T4);
            dp2[i]=min(dp2[i-1]+T3,dp1[i-1]+T4+T3);
        }else if(v1[i-1]==v1[i]){
            dp1[i]=min(dp1[i-1]+T1,dp2[i-1]+T4+T1);
            dp2[i]=min(dp1[i-1]+T4+T1,dp2[i-1]+T1);
        }else if(v1[i-1]+1==v1[i]){
            int t=min(dp2[i-1]+T3+T4,dp2[i-1]+T2+T4);
            dp1[i]=min(dp1[i-1]+T2,t);
            t=min(dp1[i-1]+T4+T2,dp1[i-1]+T4+T3);
            dp2[i]=min(dp2[i-1]+T3,t);
        }else if(v2[i-1]+1 < v2[i]){//v1[i-1] > 1+v1[i]
            dp1[i]=min(dp1[i-1]+T3,dp2[i-1]+T3+T4);
            dp2[i]=min(dp2[i-1]+T3+T4+T4,dp1[i-1]+T4+T3);
        }else{
           int t=min(dp1[i-1]+T4+T3,dp1[i-1]+T2+T4);
           dp2[i]=min(dp2[i-1]+T2,t);
           t=min(dp2[i-1]+T4+T2,dp2[i-1]+T4+T3);
           dp1[i]=min(dp1[i-1]+T3,t);
        }
    }
    cout << min(dp1[N-1],dp2[N-1])<<endl;
    return 0;
}